package com.example.storageservice.web;

import com.example.storageservice.entity.Product;
import com.example.storageservice.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * program: springcloud-seata
 * description:
 * author: Mr.Yiu
 * create: 2021-05-20 16:47
 **/
@RestController
@RequestMapping("/storage")
public class StorageController {
    @Autowired
    ProductService productService;

    @GetMapping("/hi")
    public Product hi(){
        return productService.findProduct(2);
    }

    @GetMapping("/list")
    public List<Product> findProductList(){
        return productService.findProductList();
    }

    @PostMapping("/deduct")
    public Map<String,Object> deductStorage(@RequestParam("id") int id, @RequestParam("num") int num){
        return productService.deductProduct(id, num);
    }
}
